Passed
Pull Request — master (#1)
by Muhammad Dyas
02:04
created

add-option-form.ts ➔ buildAddOptionForm   A

Complexity

Conditions 1

Size

Total Lines 38
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 38
c 0
b 0
f 0
rs 9.232
cc 1
1
/**
2
 * Build the add option form.
3
 *
4
 * @param {object} state - the current message state
5
 * @returns {object} card
6
 */
7
export function buildAddOptionForm(state) {
8
  return {
9
    'header': {
10
      'title': 'Add a new option/choice',
11
      'subtitle': 'Q:' + state.topic,
12
    },
13
    'sections': [
14
      {
15
        'widgets': [
16
          {
17
            'textInput': {
18
              'label': 'Option Name',
19
              'type': 'SINGLE_LINE',
20
              'name': 'value',
21
              'hintText': '',
22
              'value': '',
23
            },
24
            'horizontalAlignment': 'START',
25
          },
26
        ],
27
      },
28
    ],
29
    'fixedFooter': {
30
      'primaryButton': {
31
        'text': 'Add option',
32
        'onClick': {
33
          'action': {
34
            'function': 'add_option',
35
            'parameters': [
36
              {
37
                key: 'state',
38
                value: JSON.stringify(state),
39
              }],
40
          },
41
        },
42
      },
43
    },
44
  };
45
}
46